package com.fsnbigdata.service.impl;
import com.fsnbigdata.service.api.GermplasmService;
import org.springframework.roo.addon.layers.service.annotations.RooServiceImpl;
import com.fsnbigdata.domain.Germplasm;
import com.fsnbigdata.domain.Organism;
import com.fsnbigdata.repository.GermplasmRepository;
import io.springlets.data.domain.GlobalSearch;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * = GermplasmServiceImpl
 *
 * TODO Auto-generated class documentation
 *
 */
@RooServiceImpl(service = GermplasmService.class)
@Service
@Transactional(readOnly = true)
public class GermplasmServiceImpl implements GermplasmService {

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    private GermplasmRepository germplasmRepository;

    /**
     * TODO Auto-generated constructor documentation
     *
     * @param germplasmRepository
     */
    @Autowired
    public GermplasmServiceImpl(GermplasmRepository germplasmRepository) {
        setGermplasmRepository(germplasmRepository);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return GermplasmRepository
     */
    public GermplasmRepository getGermplasmRepository() {
        return germplasmRepository;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param germplasmRepository
     */
    public void setGermplasmRepository(GermplasmRepository germplasmRepository) {
        this.germplasmRepository = germplasmRepository;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param entity
     * @return Germplasm
     */
    @Transactional
    public Germplasm save(Germplasm entity) {
        return getGermplasmRepository().save(entity);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return Germplasm
     */
    public Germplasm findOne(Long id) {
        return getGermplasmRepository().findOne(id);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return Germplasm
     */
    public Germplasm findOneForUpdate(Long id) {
        return getGermplasmRepository().findOneDetached(id);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param ids
     * @return List
     */
    public List<Germplasm> findAll(Iterable<Long> ids) {
        return getGermplasmRepository().findAll(ids);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param organism
     * @param globalSearch
     * @param pageable
     * @return Page
     */
    public Page<Germplasm> findByOrganism(Organism organism, GlobalSearch globalSearch, Pageable pageable) {
        return getGermplasmRepository().findByOrganism(organism, globalSearch, pageable);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param organism
     * @return Long
     */
    public long countByOrganism(Organism organism) {
        return getGermplasmRepository().countByOrganism(organism);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Class
     */
    public Class<Germplasm> getEntityType() {
        return Germplasm.class;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Class
     */
    public Class<Long> getIdType() {
        return Long.class;
    }
}
